package me.zhengjie.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * RestTemplate配置
 */
@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate() {
        HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
        // 增加超时时间
        httpRequestFactory.setConnectTimeout(60000); // 60秒连接超时
        httpRequestFactory.setReadTimeout(60000);    // 60秒读取超时
        return new RestTemplate(httpRequestFactory);
    }
} 